home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2004 November
/
CMCD1104.ISO
/
Software
/
Freeware
/
Grafica
/
galeroo
/
Setup Galleroo 3.4.exe
/
{app}
/
styles
/
Digum
/
gallery.xsl
Wrap
Extensible Markup Language
|
2004-09-20
|
38KB
|
845 lines
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:exsl="http://exslt.org/common"
xmlns:func="http://exslt.org/functions"
xmlns:dyn="http://exslt.org/dynamic"
xmlns:math="http://exslt.org/math"
xmlns:str="http://exslt.org/strings"
xmlns:g="."
xmlns:galleroo="."
extension-element-prefixes="dyn func exsl math str g galleroo"
version='1.1'>
<xsl:include href="../Lib/galleroo.xsl" />
<xsl:output method="html" />
<!-- doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN" indent="yes" -->
<!-- Galleroo Digum XSL XML->HTML stylesheet 1.1
Copyright 2004, all rights reserved, xyster.net
written: 2/21/04
modified:
author: xyster
-->
<xsl:param name="source-folder" />
<xsl:param name="gallery-folder" />
<xsl:param name="image-size">640</xsl:param>
<xsl:param name="thumb-size">128</xsl:param>
<xsl:param name="sort-by">date</xsl:param>
<xsl:param name="title">Photo Gallery</xsl:param>
<xsl:param name="sub-title" />
<xsl:param name="html-file-prefix" />
<xsl:param name="do-three-stage">no</xsl:param>
<xsl:param name="do-auto-play-movies">no</xsl:param>
<xsl:param name="template-folder" />
<xsl:param name="_preview">0</xsl:param>
<xsl:variable name="template-folder-uri" select="str:encode-uri($template-folder, 'UTF-8')" />
<xsl:variable name="index-template" select="concat('/', $template-folder-uri, '/index.html')" />
<xsl:variable name="slide-template" select="concat('/', $template-folder-uri, '/slide.html')" />
<xsl:variable name="params"> source-folder sort-by title sub-title thumb-size html-file-prefix do-auto-play-movies template-folder index-template slide-template do-three-stage </xsl:variable>
<!-- functions -->
<!-- gets the number of thumbs declared in the index template -->
<func:function name="g:thumbs-per-index">
<xsl:param name="doc" />
<xsl:choose>
<xsl:when test="count($doc/html/gal-index/@io) != 0">
<func:result select="g:a(0, $doc/html/gal-index/@io)" />
</xsl:when>
<xsl:otherwise>
<func:result select="g:tmax($doc) - g:tmin($doc) + 1" />
</xsl:otherwise>
</xsl:choose>
</func:function>
<!-- Calculates position based on i + offset -->
<func:function name="g:a">
<xsl:param name="i" />
<xsl:param name="o" />
<xsl:choose>
<xsl:when test="substring($o, 1, 1) = '+'">
<func:result select="$i + number(substring($o, 2, string-length($o) - 1))" />
</xsl:when>
<xsl:when test="string(number($o)) = 'NaN'">
<func:result select="$i" />
</xsl:when>
<xsl:otherwise>
<func:result select="$i + number($o)" />
</xsl:otherwise>
</xsl:choose>
</func:function>
<func:function name="g:valid-param">
<xsl:param name="p" />
<func:result select="string-length(substring-after($params, $p)) != 0" />
</func:function>
<func:function name="g:tmax">
<xsl:param name="p" />
<xsl:choose>
<xsl:when test="count($p/*) != 0">
<xsl:variable name="c">
<a>
<xsl:for-each select="$p/*">
<o><xsl:value-of select="g:tmax(.)" /></o>
</xsl:for-each>
</a>
</xsl:variable>
<xsl:choose>
<xsl:when test="count(exsl:node-set($c)/a/o) != 0">
<xsl:variable name="d" select="math:max(exsl:node-set($c)/a/o)" />
<xsl:choose>
<xsl:when test="$d < 0">
<func:result select="g:a(0, $p/@io)" />
</xsl:when>
<xsl:otherwise>
<func:result select="g:a($d, $p/@io)" />
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<func:result select="g:a(0, $p/@io)" />
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<func:result select="g:a(0, $p/@io)" />
</xsl:otherwise>
</xsl:choose>
</func:function>
<func:function name="g:tmin">
<xsl:param name="p" />
<xsl:choose>
<xsl:when test="count($p/*) != 0">
<xsl:variable name="c">
<a>
<xsl:for-each select="$p/*">
<o><xsl:value-of select="g:tmin(.)" /></o>
</xsl:for-each>
</a>
</xsl:variable>
<xsl:choose>
<xsl:when test="count(exsl:node-set($c)/a/o) != 0">
<xsl:variable name="d" select="math:min(exsl:node-set($c)/a/o)" />
<xsl:choose>
<xsl:when test="$d > 0">
<func:result select="g:a(0, $p/@io)" />
</xsl:when>
<xsl:otherwise>
<func:result select="g:a($d, $p/@io)" />
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<func:result select="g:a(0, $p/@io)" />
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<func:result select="g:a(0, $p/@io)" />
</xsl:otherwise>
</xsl:choose>
</func:function>
<func:function name="g:ftl">
<xsl:param name="s" />
<xsl:variable name="n1" select="string-length($s)" />
<xsl:variable name="n2" select="string-length(substring-before($s, ' '))" />
<xsl:choose>
<xsl:when test="$n2 != 0">
<func:result select="$n2" />
</xsl:when>
<xsl:otherwise>
<func:result select="$n1" />
</xsl:otherwise>
</xsl:choose>
</func:function>
<xsl:template match="list">
<!-- yummy! copy over the pix to a new *sorted* list
-->
<xsl:variable name="sorted-pix" select="exsl:node-set(galleroo:sort-pix(media/object/children/object/children/object, $sort-by))" />
<xsl:variable name="maxi" select="count($sorted-pix/*)" />
<xsl:variable name="iperj" select="g:thumbs-per-index(document($index-template))" />
<xsl:variable name="maxj" select="floor(($maxi + ($iperj - 1)) div $iperj)" />
<!-- index -->
<xsl:if test="count(document($index-template)/*) != 0">
<xsl:for-each select="$sorted-pix/*[position() mod $iperj = 1]">
<xsl:apply-templates select="document($index-template)" mode="gal">
<xsl:with-param name="pix" select="$sorted-pix/*" />
<xsl:with-param name="i" select="(position() - 1) * $iperj + 1" />
<xsl:with-param name="maxi" select="$maxi" />
<xsl:with-param name="j" select="position()" />
<xsl:with-param name="maxj" select="$maxj" />
<xsl:with-param name="iperj" select="$iperj" />
</xsl:apply-templates>
<!-- cutter output -->
<xsl:call-template name="gal-emit-cutter-index">
<xsl:with-param name="index" select="position()" />
<xsl:with-param name="html-file-prefix" select="$html-file-prefix" />
</xsl:call-template>
</xsl:for-each>
</xsl:if>
<!-- slide -->
<xsl:if test="count(document($slide-template)/*) != 0">
<xsl:for-each select="$sorted-pix/*">
<xsl:apply-templates select="document($slide-template)" mode="gal">
<xsl:with-param name="pix" select="$sorted-pix/*" />
<xsl:with-param name="i" select="position()" />
<xsl:with-param name="maxi" select="$maxi" />
<xsl:with-param name="j" select="floor((position() + ($iperj - 1)) div $iperj)" />
<xsl:with-param name="maxj" select="$maxj" />
<xsl:with-param name="iperj" select="$iperj" />
</xsl:apply-templates>
<!-- cutter output -->
<xsl:text> </xsl:text>
<xsl:comment>CUTHERE: <xsl:value-of select="galleroo:rplstr(concat($html-file-prefix, attrib/name), '-', '\-')" />.html ?</xsl:comment>
<xsl:text> </xsl:text>
</xsl:for-each>
</xsl:if>
</xsl:template>
<xsl:template match="*|node()" mode="gal">
<xsl:param name="pix" />
<xsl:param name="i" />
<xsl:param name="maxi" />
<xsl:param name="j" />
<xsl:param name="maxj" />
<xsl:param name="iperj" />
<xsl:variable name="l" select="string-length(name())" />
<xsl:variable name="io" select="g:a($i, @io)" />
<xsl:variable name="jo" select="g:a($j, @jo)" />
<xsl:choose>
<!-- fancy directives -->
<!-- super index generator -->
<xsl:when test="name() = 'gal-sindex'">
<!-- process everything inside -->
<xsl:apply-templates mode="gal">
<xsl:with-param name="pix" select="$pix" />
<xsl:with-param name="i" select="$io" />
<xsl:with-param name="maxi" select="$maxi" />
<xsl:with-param name="j" select="$jo" />
<xsl:with-param name="maxj" select="$maxj" />
<xsl:with-param name="iperj" select="$iperj" />
</xsl:apply-templates>
<!-- regenerate it again! -->
<xsl:copy-of select="." />
</xsl:when>
<!-- super hyper generic XPath conditional -->
<xsl:when test="name() = 'gal-if-xpath'">
<xsl:if test="dyn:evaluate(@test)">
<xsl:apply-templates mode="gal">
<xsl:with-param name="pix" select="$pix" />
<xsl:with-param name="i" select="$io" />
<xsl:with-param name="maxi" select="$maxi" />
<xsl:with-param name="j" select="$jo" />
<xsl:with-param name="maxj" select="$maxj" />
<xsl:with-param name="iperj" select="$iperj" />
</xsl:apply-templates>
</xsl:if>
</xsl:when>
<!-- super hyper generic XPath expression evaluation -->
<xsl:when test="name() = 'gal-xpath'">
<xsl:value-of select="dyn:evaluate(@xpath)" />
</xsl:when>
<!-- offsetter -->
<xsl:when test="name() = 'gal-offset'">
<xsl:choose>
<xsl:when test="@absolute">
<xsl:apply-templates mode="gal">
<xsl:with-param name="pix" select="$pix" />
<xsl:with-param name="i" select="g:a(0, @io)" />
<xsl:with-param name="maxi" select="$maxi" />
<xsl:with-param name="j" select="g:a(0, @jo)" />
<xsl:with-param name="maxj" select="$maxj" />
<xsl:with-param name="iperj" select="$iperj" />
</xsl:apply-templates>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates mode="gal">
<xsl:with-param name="pix" select="$pix" />
<xsl:with-param name="i" select="$io" />
<xsl:with-param name="maxi" select="$maxi" />
<xsl:with-param name="j" select="$jo" />
<xsl:with-param name="maxj" select="$maxj" />
<xsl:with-param name="iperj" select="$iperj" />
</xsl:apply-templates>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<!-- index cursor elements -->
<xsl:when test="name() = 'gal-index'">
<!-- do nothing! -->
</xsl:when>
<xsl:when test="name() = 'gal-if-index-valid'">
<xsl:if test="$jo > 0 and $jo <= $maxj">
<xsl:apply-templates mode="gal">
<xsl:with-param name="pix" select="$pix" />
<xsl:with-param name="i" select="$io" />
<xsl:with-param name="maxi" select="$maxi" />
<xsl:with-param name="j" select="$jo" />
<xsl:with-param name="maxj" select="$maxj" />
<xsl:with-param name="iperj" select="$iperj" />
</xsl:apply-templates>
</xsl:if>
</xsl:when>
<xsl:when test="name() = 'gal-if-index-not-valid'">
<xsl:if test="not ($jo > 0 and $jo <= $maxj)">
<xsl:apply-templates mode="gal">
<xsl:with-param name="pix" select="$pix" />
<xsl:with-param name="i" select="$io" />
<xsl:with-param name="maxi" select="$maxi" />
<xsl:with-param name="j" select="$jo" />
<xsl:with-param name="maxj" select="$maxj" />
<xsl:with-param name="iperj" select="$iperj" />
</xsl:apply-templates>
</xsl:if>
</xsl:when>
<!-- gallery if/if-not directive -->
<xsl:when test="substring(name(), 1, 14) = 'gal-gallery-if'">
<xsl:variable name="p" select="substring(name(), 13, 6)" />
<xsl:variable name="a" select="substring(name(), 16, $l)" />
<xsl:variable name="an" select="substring(name(), 20, $l)" />
<xsl:choose>
<xsl:when test="$p = 'if-not' and g:valid-param($an)">
<xsl:if test="dyn:evaluate(concat('$', $an)) != @value" >
<xsl:apply-templates mode="gal">
<xsl:with-param name="pix" select="$pix" />
<xsl:with-param name="i" select="$io" />
<xsl:with-param name="maxi" select="$maxi" />
<xsl:with-param name="j" select="$jo" />
<xsl:with-param name="maxj" select="$maxj" />
<xsl:with-param name="iperj" select="$iperj" />
</xsl:apply-templates>
</xsl:if>
</xsl:when>
<xsl:when test="g:valid-param($a)">
<xsl:if test="dyn:evaluate(concat('$', $a)) = @value" >
<xsl:apply-templates mode="gal">
<xsl:with-param name="pix" select="$pix" />
<xsl:with-param name="i" select="$io" />
<xsl:with-param name="maxi" select="$maxi" />
<xsl:with-param name="j" select="$jo" />
<xsl:with-param name="maxj" select="$maxj" />
<xsl:with-param name="iperj" select="$iperj" />
</xsl:apply-templates>
</xsl:if>
</xsl:when>
</xsl:choose>
</xsl:when>
<!-- image cursor elements -->
<xsl:when test="name() = 'gal-if-image-valid'">
<xsl:if test="$io > 0 and $io <= $maxi">
<xsl:apply-templates mode="gal">
<xsl:with-param name="pix" select="$pix" />
<xsl:with-param name="i" select="$io" />
<xsl:with-param name="maxi" select="$maxi" />
<xsl:with-param name="j" select="$jo" />
<xsl:with-param name="maxj" select="$maxj" />
<xsl:with-param name="iperj" select="$iperj" />
</xsl:apply-templates>
</xsl:if>
</xsl:when>
<xsl:when test="name() = 'gal-if-image-not-valid'">
<xsl:if test="not ($io > 0 and $io <= $maxi)">
<xsl:apply-templates mode="gal">
<xsl:with-param name="pix" select="$pix" />
<xsl:with-param name="i" select="$io" />
<xsl:with-param name="maxi" select="$maxi" />
<xsl:with-param name="j" select="$jo" />
<xsl:with-param name="maxj" select="$maxj" />
<xsl:with-param name="iperj" select="$iperj" />
</xsl:apply-templates>
</xsl:if>
</xsl:when>
<!-- image conditional catch-all -->
<xsl:when test="substring(name(), 1, 12) = 'gal-image-if'">
<xsl:variable name="p" select="substring(name(), 11, 6)" />
<xsl:variable name="a" select="substring(name(), 14, $l)" />
<xsl:variable name="an" select="substring(name(), 18, $l)" />
<xsl:choose>
<xsl:when test="$p = 'if-not'">
<xsl:choose>
<xsl:when test="substring($an, 1, 5) = 'iptc-'">
<xsl:variable name="iname" select="galleroo:iptc-num($an)" />
<xsl:variable name="cnt" select="count($pix[$io]/attrib/*[name() = $iname])" />
<xsl:if test="($cnt != 0 and @value != $pix[$io]/attrib/*[name() = $iname]) or
($cnt = 0 and @exists='1') or
($cnt != 0 and @exists='0')">
<xsl:apply-templates mode="gal">
<xsl:with-param name="pix" select="$pix" />
<xsl:with-param name="i" select="$io" />
<xsl:with-param name="maxi" select="$maxi" />
<xsl:with-param name="j" select="$jo" />
<xsl:with-param name="maxj" select="$maxj" />
<xsl:with-param name="iperj" select="$iperj" />
</xsl:apply-templates>
</xsl:if>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="cnt" select="count($pix[$io]/attrib/*[name() = $an])" />
<xsl:if test="($cnt != 0 and @value != $pix[$io]/attrib/*[name() = $an]) or
($cnt = 0 and @exists='1') or
($cnt != 0 and @exists='0')">
<xsl:apply-templates mode="gal">
<xsl:with-param name="pix" select="$pix" />
<xsl:with-param name="i" select="$io" />
<xsl:with-param name="maxi" select="$maxi" />
<xsl:with-param name="j" select="$jo" />
<xsl:with-param name="maxj" select="$maxj" />
<xsl:with-param name="iperj" select="$iperj" />
</xsl:apply-templates>
</xsl:if>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="substring($a, 1, 5) = 'iptc-'">
<xsl:variable name="iname" select="galleroo:iptc-num($a)" />
<xsl:variable name="cnt" select="count($pix[$io]/attrib/*[name() = $iname])" />
<xsl:if test="($cnt != 0 and @value = $pix[$io]/attrib/*[name() = $iname]) or
($cnt != 0 and @exists='1') or
($cnt = 0 and @exists='0')">
<xsl:apply-templates mode="gal">
<xsl:with-param name="pix" select="$pix" />
<xsl:with-param name="i" select="$io" />
<xsl:with-param name="maxi" select="$maxi" />
<xsl:with-param name="j" select="$jo" />
<xsl:with-param name="maxj" select="$maxj" />
<xsl:with-param name="iperj" select="$iperj" />
</xsl:apply-templates>
</xsl:if>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="cnt" select="count($pix[$io]/attrib/*[name() = $a])" />
<xsl:if test="($cnt != 0 and @value = $pix[$io]/attrib/*[name() = $a]) or
($cnt != 0 and @exists='1') or
($cnt = 0 and @exists='0')">
<xsl:apply-templates mode="gal">
<xsl:with-param name="pix" select="$pix" />
<xsl:with-param name="i" select="$io" />
<xsl:with-param name="maxi" select="$maxi" />
<xsl:with-param name="j" select="$jo" />
<xsl:with-param name="maxj" select="$maxj" />
<xsl:with-param name="iperj" select="$iperj" />
</xsl:apply-templates>
</xsl:if>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<!-- full image -->
<xsl:when test="name() = 'gal-image-full'">
<!-- the full size image/video -->
<xsl:choose>
<!-- video -->
<xsl:when test="$pix[$io]/attrib/format = 'video'">
<div>
<embed class="slide" src="{$pix[$io]/attrib/full-path}/{$pix[$io]/attrib/name}" mute="0" enablecontextmenu="1" showdisplay="0" autostart="{$do-auto-play-movies = 'yes'}" playcount="1" showcontrols="1" />
</div>
<div>
<a href="{$pix[$io]/attrib/full-path}/{$pix[$io]/attrib/name}"><xsl:value-of select="galleroo:pretty-name($pix[$io]/attrib/name)" /> (<xsl:number value="$pix[$io]/attrib/file-size div 1024" grouping-separator="," grouping-size="3" />KB)</a>
</div>
</xsl:when>
<!-- image -->
<xsl:otherwise>
<div>
<img class="slide" src="{$pix[$io]/attrib/full-path}/{$pix[$io]/attrib/name}" border="0" />
</div>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<!-- handle expression evaluation -->
<xsl:when test="name() = 'gal-eval'">
<xsl:call-template name="evaluator">
<xsl:with-param name="s" select="@expr" />
<xsl:with-param name="pix" select="$pix" />
<xsl:with-param name="i" select="$io" />
<xsl:with-param name="maxi" select="$maxi" />
<xsl:with-param name="j" select="$jo" />
<xsl:with-param name="maxj" select="$maxj" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="braced-name" select="concat('{', name(), '}')" />
<!-- call our magic evaluator -->
<xsl:variable name="expanded">
<xsl:call-template name="evaluator">
<xsl:with-param name="s" select="$braced-name" />
<xsl:with-param name="pix" select="$pix" />
<xsl:with-param name="i" select="$io" />
<xsl:with-param name="maxi" select="$maxi" />
<xsl:with-param name="j" select="$jo" />
<xsl:with-param name="maxj" select="$maxj" />
</xsl:call-template>
</xsl:variable>
<xsl:choose>
<!-- string expandable directives -->
<xsl:when test="$expanded != name()">
<xsl:value-of select="$expanded" />
</xsl:when>
<!-- recurse through -->
<xsl:otherwise>
<xsl:copy>
<xsl:for-each select="@*[name() != 'io' and name() != 'jo']">
<xsl:attribute name="{name()}">
<xsl:call-template name="evaluator">
<xsl:with-param name="s" select="." />
<xsl:with-param name="pix" select="$pix" />
<xsl:with-param name="i" select="$io" />
<xsl:with-param name="maxi" select="$maxi" />
<xsl:with-param name="j" select="$jo" />
<xsl:with-param name="maxj" select="$maxj" />
</xsl:call-template>
</xsl:attribute>
</xsl:for-each>
<xsl:apply-templates mode="gal">
<xsl:with-param name="pix" select="$pix" />
<xsl:with-param name="i" select="$io" />
<xsl:with-param name="maxi" select="$maxi" />
<xsl:with-param name="j" select="$jo" />
<xsl:with-param name="maxj" select="$maxj" />
<xsl:with-param name="iperj" select="$iperj" />
</xsl:apply-templates>
</xsl:copy>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="evaluator">
<xsl:param name="s" />
<xsl:param name="pix" />
<xsl:param name="i" />
<xsl:param name="maxi" />
<xsl:param name="j" />
<xsl:param name="maxj" />
<xsl:choose>
<xsl:when test="contains($s, '{')">
<xsl:value-of select="substring-before($s, '{')" />
<xsl:variable name="expression" select="substring-before(substring-after($s, '{'), '}')" />
<xsl:variable name="expanded-expression">
<xsl:call-template name="expander">
<xsl:with-param name="s" select="$expression" />
<xsl:with-param name="pix" select="$pix" />
<xsl:with-param name="i" select="$i" />
<xsl:with-param name="maxi" select="$maxi" />
<xsl:with-param name="j" select="$j" />
<xsl:with-param name="maxj" select="$maxj" />
</xsl:call-template>
</xsl:variable>
<xsl:value-of select="$expanded-expression" />
<!-- evaluate the next expression down the line -->
<xsl:call-template name="evaluator">
<xsl:with-param name="s" select="substring-after($s, '}')" />
<xsl:with-param name="pix" select="$pix" />
<xsl:with-param name="i" select="$i" />
<xsl:with-param name="maxi" select="$maxi" />
<xsl:with-param name="j" select="$j" />
<xsl:with-param name="maxj" select="$maxj" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$s" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="expander">
<xsl:param name="s" />
<xsl:param name="pix" />
<xsl:param name="i" />
<xsl:param name="maxi" />
<xsl:param name="j" />
<xsl:param name="maxj" />
<!-- gal-gallery special cases -->
<xsl:variable name="n1">
<xsl:call-template name="rplstr">
<xsl:with-param name="value" select="$s"/>
<xsl:with-param name="from" select="'gal-gallery-generator'" />
<xsl:with-param name="to" select="$source-root/list/generator" />
</xsl:call-template>
</xsl:variable>
<!-- gal-gallery catch all -->
<xsl:variable name="n2">
<xsl:call-template name="gal-gallery">
<xsl:with-param name="value" select="$n1" />
</xsl:call-template>
</xsl:variable>
<!-- gal-image special cases -->
<xsl:variable name="n3">
<xsl:call-template name="rplstr">
<xsl:with-param name="value" select="$n2"/>
<xsl:with-param name="from" select="'gal-image-title'" />
<xsl:with-param name="to" select="galleroo:image-title($pix[$i]/attrib)" />
</xsl:call-template>
</xsl:variable>
<xsl:variable name="n4">
<xsl:call-template name="rplstr">
<xsl:with-param name="value" select="$n3"/>
<xsl:with-param name="from" select="'gal-image-comment'" />
<xsl:with-param name="to" select="galleroo:image-comment($pix[$i]/attrib)" />
</xsl:call-template>
</xsl:variable>
<xsl:variable name="n5">
<xsl:call-template name="rplstr">
<xsl:with-param name="value" select="$n4"/>
<xsl:with-param name="from" select="'gal-image-pretty-name'" />
<xsl:with-param name="to" select="galleroo:pretty-name($pix[$i]/attrib/name)" />
</xsl:call-template>
</xsl:variable>
<xsl:variable name="n6">
<xsl:call-template name="rplstr">
<xsl:with-param name="value" select="$n5" />
<xsl:with-param name="from" select="'gal-image-thumb-src'" />
<xsl:with-param name="to" select="concat($pix[$i]/attrib/thumb-path, '/', $pix[$i]/attrib/thumb-name)" />
</xsl:call-template>
</xsl:variable>
<xsl:variable name="n7">
<xsl:call-template name="rplstr">
<xsl:with-param name="value" select="$n6" />
<xsl:with-param name="from" select="'gal-image-full-src'" />
<xsl:with-param name="to" select="concat($pix[$i]/attrib/full-path, '/', $pix[$i]/attrib/name)" />
</xsl:call-template>
</xsl:variable>
<xsl:variable name="n8">
<xsl:call-template name="rplstr">
<xsl:with-param name="value" select="$n7" />
<xsl:with-param name="from" select="'gal-image-full-href'" />
<xsl:with-param name="to" select="concat($html-file-prefix, $pix[$i]/attrib/name, '.html')" />
</xsl:call-template>
</xsl:variable>
<xsl:variable name="n9">
<xsl:choose>
<xsl:when test="boolean($pix[$i]/attrib/original-path)">
<xsl:call-template name="rplstr">
<xsl:with-param name="value" select="$n8" />
<xsl:with-param name="from" select="'gal-image-original-href'" />
<xsl:with-param name="to" select="concat($pix[$i]/attrib/original-path, '/', $pix[$i]/attrib/name)" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="rplstr">
<xsl:with-param name="value" select="$n8" />
<xsl:with-param name="from" select="'gal-image-original-href'" />
<xsl:with-param name="to" select="''" />
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="n10">
<xsl:variable name="exposure" select="$pix[$i]/attrib/exposure-time" />
<xsl:variable name="pretty-exposure">
<xsl:choose>
<xsl:when test="count($pix[$i]/attrib/exposure-time) = 0" />
<xsl:when test="$exposure >= 1.0 or $exposure <= 0.0"><xsl:value-of select="$exposure" />"</xsl:when>
<xsl:otherwise>1/<xsl:value-of select="round(1.0 div $exposure)" /></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:call-template name="rplstr">
<xsl:with-param name="value" select="$n9" />
<xsl:with-param name="from" select="'gal-image-exposure-time'" />
<xsl:with-param name="to" select="$pretty-exposure" />
</xsl:call-template>
</xsl:variable>
<xsl:variable name="n11">
<xsl:call-template name="rplstr">
<xsl:with-param name="value" select="$n10" />
<xsl:with-param name="from" select="'gal-image-num'" />
<xsl:with-param name="to" select="$i" />
</xsl:call-template>
</xsl:variable>
<xsl:variable name="n12">
<xsl:call-template name="rplstr">
<xsl:with-param name="value" select="$n11" />
<xsl:with-param name="from" select="'gal-image-max'" />
<xsl:with-param name="to" select="$maxi" />
</xsl:call-template>
</xsl:variable>
<!-- gal-image catch all -->
<xsl:variable name="n13">
<xsl:call-template name="gal-image">
<xsl:with-param name="value" select="$n12" />
<xsl:with-param name="pix" select="$pix" />
<xsl:with-param name="i" select="$i" />
</xsl:call-template>
</xsl:variable>
<!-- index cases -->
<xsl:variable name="n14">
<xsl:call-template name="rplstr">
<xsl:with-param name="value" select="$n13" />
<xsl:with-param name="from" select="'gal-index-href'" />
<xsl:with-param name="to" select="concat($html-file-prefix, galleroo:index-html-name($j))" />
</xsl:call-template>
</xsl:variable>
<xsl:variable name="n15">
<xsl:call-template name="rplstr">
<xsl:with-param name="value" select="$n14" />
<xsl:with-param name="from" select="'gal-index-max'" />
<xsl:with-param name="to" select="$maxj" />
</xsl:call-template>
</xsl:variable>
<xsl:variable name="n16">
<xsl:call-template name="rplstr">
<xsl:with-param name="value" select="$n15" />
<xsl:with-param name="from" select="'gal-index-num'" />
<xsl:with-param name="to" select="$j" />
</xsl:call-template>
</xsl:variable>
<xsl:value-of select="$n16" />
</xsl:template>
<xsl:template name="gal-gallery">
<xsl:param name="value" />
<xsl:variable name="base" select="'gal-gallery-'" />
<xsl:choose>
<xsl:when test="contains($value, $base)">
<xsl:variable name="token-length" select="g:ftl(substring-after($value, $base))" />
<xsl:variable name="token-name" select="substring(substring-after($value, $base), 1, $token-length)" />
<xsl:value-of select="substring-before($value, $base)" />
<xsl:if test="g:valid-param($token-name)">
<xsl:value-of select="dyn:evaluate(concat('$', $token-name))" />
</xsl:if>
<xsl:call-template name="gal-gallery">
<xsl:with-param name="value" select="substring(substring-after($value, $base), $token-length + 1)" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$value" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="gal-image">
<xsl:param name="value" />
<xsl:param name="pix" />
<xsl:param name="i" />
<xsl:variable name="base" select="'gal-image-'" />
<xsl:choose>
<xsl:when test="contains($value, $base)">
<xsl:variable name="token-length" select="g:ftl(substring-after($value, $base))" />
<xsl:variable name="token-name" select="substring(substring-after($value, $base), 1, $token-length)" />
<xsl:value-of select="substring-before($value, $base)" />
<xsl:choose>
<xsl:when test="substring($token-name, 1, 5) = 'iptc-'">
<xsl:value-of select="galleroo:iptc($pix[$i]/attrib, $token-name)" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$pix[$i]/attrib/*[name() = $token-name]" />
</xsl:otherwise>
</xsl:choose>
<xsl:call-template name="gal-image">
<xsl:with-param name="value" select="substring(substring-after($value, $base), $token-length + 1)" />
<xsl:with-param name="pix" select="$pix" />
<xsl:with-param name="i" select="$i" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$value" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="rplstr">
<xsl:param name="value" />
<xsl:param name="from" />
<xsl:param name="to" />
<xsl:choose>
<xsl:when test="contains($value, $from)">
<xsl:value-of select="substring-before($value, $from)" />
<xsl:value-of select="$to" />
<xsl:call-template name="rplstr">
<xsl:with-param name="value" select="substring-after($value, $from)" />
<xsl:with-param name="from" select="$from" />
<xsl:with-param name="to" select="$to" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$value" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>